package com.jxs.android.weiget;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.jxs.android.ges.GesApplication;
import com.jxs.android.ges.R;

public class PopMsg {

	public static void show_bak(String msg, Integer... duration) {
		Context context = GesApplication.getApplication();
		final Toast toast = new Toast(context);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View contentView = inflater.inflate(R.layout.pop_msg_bar, null);
		((TextView) contentView.findViewById(R.id.alert_message)).setText(msg);
		toast.setView(contentView);
		if (null == duration) {
			toast.setDuration(1500);
		} else if (null != duration && duration.length == 1) {
			toast.setDuration(duration[0]);
		}
		toast.setGravity(Gravity.CENTER_VERTICAL, 0, 75);
		toast.show();
	}

	public static void show_bak(int msgId, Integer... duration) {
		Context context = GesApplication.getApplication();
		show_bak(context.getString(msgId), duration);
	}

	public static void show(Context context, int msgId) {
		show(context, context.getString(msgId));
	}

	public static void show(Context context, String msg, BuAlertDailog.IPhoneAlertDailog alertOkListener) {
		try {
			BuAlertDailog.builder(context, context.getString(R.string.promp_tip), msg, alertOkListener).show();
		} catch (Exception e) {

		}
	}

	public static void show(Context context, int msgId, BuAlertDailog.IPhoneAlertDailog alertOkListener) {
		try {
			BuAlertDailog.builder(context, context.getString(R.string.promp_tip), context.getString(msgId), alertOkListener).show();
		} catch (Exception e) {

		}
	}

	public static void show(Context context, String msg) {
		try {
			BuAlertDailog.builder(context, context.getString(R.string.promp_tip), msg, new BuAlertDailog.IPhoneAlertDailog() {
				@Override
				public void okLogic(Dialog dialog) {
					dialog.dismiss();
				}
				@Override
				public String getOkText(Context context) {
					return context.getString(R.string.prompt_confirm);
				}
			}).show();
		} catch (Exception e) {

		}
	}
}
